<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<title></title>
		<meta name="renderer" content="webkit">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
		<link rel="stylesheet" href="../../../layuiadmin/layui/css/layui.css" media="all">
		<link rel="stylesheet" href="../../../layuiadmin/style/admin.css" media="all">
		<link rel="stylesheet" href="../../../css/common.css" media="all">
		<style type="text/css">
			.layui-form-item {
				margin-top: 10px;
				margin-right: 80px;
			}
			.form-bc{
				background-color: #fff;
			}
		</style>
	</head>

	<body>
			<form class="layui-form test_edit" lay-filter="test_detail" id="fo">
				<div class="form-bc">
					<div class="layui-form-item">
						<label class="layui-form-label">问题回复：</label>
						<div class="layui-input-block">
							<textarea class="layui-textarea layui-hide" name="problem_desc" lay-verify="content" id="demo_editor"></textarea>
						</div>
					</div>
					<div class="layui-form-item layui-layout-admin">
						<div class="layui-input-block">
							<div class="layui-footer" style="left: 0;">
								<button class="layui-btn" lay-submit="" lay-filter="demo1">立即提交</button>
							</div>
						</div>
					</div>
				</div>
			</form>
		<script src="../../../layuiadmin/layui/layui.js"></script>
		<script src="../../../js/jquery.min.js"></script>
		<script src="../../../js/jquery.jqprint-0.3.js"></script>
		<script src="../../../js/common.js"></script>
		<script>
			var _data = {
				orderid: getParam('orderid'),
				type:0,
				status:1
			}

			layui.config({
				base: '../../../layuiadmin/' //静态资源所在路径
			}).extend({
				tinymce: 'tinymce/tinymce',
				index: 'lib/index' //主入口模块
			}).use(['tinymce', 'index', 'form', 'laytpl', 'laydate'], function() {
				var $ = layui.$,
					admin = layui.admin,
					laytpl = layui.laytpl,
					laydate = layui.laydate,
					tinymce = layui.tinymce,
					form = layui.form;
				map_show({
					mapName: 'work_order_level',
					domType: 'radio',
					fieldName: 'level'
				})

				if(getParam('id')) {
					loading();
					initdata();
				}

				var edit = tinymce.render({
					elem: "#demo_editor",
					height: 600
				});
				
				//表单信息
				
				
				//监听提交
				form.on('submit(demo1)', function(data) {
					var data = data.field;
					_data = Object.assign(_data, data);
					layer.confirm('确定要提交数据？', function() {
						loading();
						_data.content = edit.getContent()
						if(_data.id) {
							submitdata(wd_server.erp_work_order_edit);
						} else {
							delete _data.id;
							submitdata(wd_server.erp_work_order_sub_insert);
						}
					}, function() {
						layer.msg('取消操作');
					});
					return false;
				});

				function submitdata(_url) {
					$.post(_url, _data, function(res, status) {
						if(status == 'success') {
							if(res.code == 0) {
								layer.alert(res.msg, function() {
									parent.layer.closeAll();
									parent.layui.table.reload('test-table-operate');
								});
							} else {
								layer.msg(res.msg);
							}
							closeloading();
						} else {
							closeloading();
							layer.msg('服务器连接错误');
						}
					});
				}

				function initdata() {
					$.get(server.erp_work_order_detail, _data, function(res, status) {
						if(status == 'success') {
							if(res.code == 0) {
								var data = res.erp_work_order
								form.val("test_detail", data.data);
								form.render();
							} else {
								layer.msg(res.msg);
							}
							layer.closeAll('loading')
						} else {
							layer.msg('服务器连接错误');
							layer.closeAll('loading')
						}
					});
				}

				window.check = function(data) {
					if(data == 'project') {
						layer.open({
							type: 2,
							title: '选择',
							shadeClose: false,
							shade: 0.5,
							maxmin: true, //开启最大化最小化按钮
							area: ['800px', '90%'],
							content: 'project_list.html',
							end: function() {},
							success: function() {}
						});
					} else if(data == 'app') {
						if($('.projectid').val() == undefined || $('.projectid').val() == '' || $('.projectid').val() == null) {
							layer.msg('请选择项目');
						} else {
							layer.open({
								type: 2,
								title: '选择',
								shadeClose: false,
								shade: 0.5,
								maxmin: true, //开启最大化最小化按钮
								area: ['800px', '90%'],
								content: 'app_list.html?project_id=' + $('.projectid').val(),
								end: function() {},
								success: function() {}
							});
						}
					}
				}
			});
		</script>
	</body>

</html>